// infer;
type Func = (...args: any[]) => any;
type FunctionReturnType<T extends Func> = T extends (...args: any[]) => infer R
  ? R
  : never;
type Sss = FunctionReturnType<() => string>; // string;

// infer
// 提取首尾两个
type ExtractStartAndEnd<T extends any[]> = T extends [
  infer Start,
  ...any[],
  infer End
]
  ? [Start, End]
  : T;
// 调换首尾两个
type SwapStartAndEnd<T extends any[]> = T extends [
  infer Start,
  ...infer Left,
  infer End
]
  ? [End, ...Left, Start]
  : T;

// 调换开头两个
type SwapFirstTwo<T extends any[]> = T extends [
  infer First,
  infer Second,
  ...infer Left
]
  ? [Second, First, ...Left]
  : T;

// infer 作为接口

type PropType<T, K extends keyof T> = T extends {
  [Key in K]: infer R;
}
  ? R
  : never;

type PropTypeResult1 = PropType<{ name: number }, "name">;
type PropTypeResult2 = PropType<{ name: string; age: number }, "name" | "age">;

